<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>WAP/WML</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="tips.html" title="Chapter 21. Tips &amp; Tricks">
<link rel="prev" href="tips.dates.html" title="Dates">
<link rel="next" href="tips.componentized.templates.html" title="Componentized Templates">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">WAP/WML</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="tips.dates.html">Prev</a> </td>
<th width="60%" align="center">Chapter 21. Tips &amp; Tricks</th>
<td width="20%" align="right"> <a accesskey="n" href="tips.componentized.templates.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="WAP/WML">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="tips.wap"></a>WAP/WML</h2></div></div></div>
<p>
    WAP/WML templates require a php
    <a class="ulink" href="http://php.net/header" target="_top">Content-Type header</a>
    to be passed along
    with the template. The easist way to do this would be to write a custom
    function that prints the header. If you are using
    <a class="link" href="caching.html" title="Chapter 15. Caching">caching</a>, that won't
    work so we'll do it using the
    <a class="link" href="language.function.insert.html" title="{insert}"><code class="varname">{insert}</code></a>
    tag; remember <code class="varname">{insert}</code> tags are not
    cached! Be sure that there is nothing output to the browser before the
    template, or else the header may fail.
   </p>
<div class="example">
<a name="id469060"></a><p class="title"><b>Example 21.6. Using {insert} to write a WML Content-Type header</b></p>
<div class="example-contents">
<pre class="programlisting">

&lt;?php

// be sure apache is configure for the .wml extensions!
// put this function somewhere in your application, or in Smarty.addons.php
function insert_header($params)
{
   // this function expects $content argument
   if (empty($params['content'])) {
       return;
   }
   header($params['content']);
   return;
}

?&gt;

    </pre>
<p>
     your Smarty template <span class="emphasis"><em>must</em></span> begin with the insert tag :
    </p>
<pre class="programlisting">

{insert name=header content="Content-Type: text/vnd.wap.wml"}

&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"&gt;

&lt;!-- begin new wml deck --&gt;
&lt;wml&gt;
 &lt;!-- begin first card --&gt;
 &lt;card&gt;
  &lt;do type="accept"&gt;
   &lt;go href="#two"/&gt;
  &lt;/do&gt;
  &lt;p&gt;
   Welcome to WAP with Smarty!
   Press OK to continue...
  &lt;/p&gt;
 &lt;/card&gt;
 &lt;!-- begin second card --&gt;
 &lt;card id="two"&gt;
  &lt;p&gt;
   Pretty easy isn't it?
  &lt;/p&gt;
 &lt;/card&gt;
&lt;/wml&gt;

    </pre>
</div>
</div>
<br class="example-break">
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="tips.dates.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="tips.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="tips.componentized.templates.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Dates </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Componentized Templates</td>
</tr>
</table>
</div>
</body>
</html>
